var myajax = {
//	baseurl: "http://192.168.2.216:8089/",
//	baseurl: "http://172.16.228.251:8091/",
	baseurl: "http://122.156.218.91:8091/",
	task: 0,
	closetask: function() {
		console.log(myajax.task)
		if(myajax.task == 0) {
			mui.toast('上传成功')
			mui.back()
		} else {
			myajax.task--
		}
	},
	data: {

	},
	backfun: function(data) {

	},
	post: function(url) {
		var fun = this.backfun
		var close = this.closetask
		mui.ajax(this.baseurl + url, {
			data: this.data,
			headers: {
				'Content-Type': 'application/json',
				'Authorization': localStorage.getItem("token")
			},
			dataType: 'json', //服务器返回json格式数据
			type: 'post', //HTTP请求类型
			timeout: 10000, //超时时间设置为10秒；
			success: function(data) {
				console.log(data)
				if(data["code"] == 200) {
					fun(data)
					close()
				} else {
					mui.toast('服务器在开小差')
				}
			},
			error: function(xhr, type, errorThrown) {
				mui.toast('网络连接失败')
			}
		});
	},
	get: function(url) {
		var fun = this.backfun
		
		mui.ajax(this.baseurl+url, {
			data: this.data,
			headers: {
//				'Content-Type': 'application/json',
				'Authorization': localStorage.getItem("token")
			},
			dataType: 'json', //服务器返回json格式数据
			type: 'get', //HTTP请求类型
			timeout: 10000, //超时时间设置为10秒；
			success: function(data) {
				console.log(data)

				if(data["code"] == 200) {
					fun(data)
					
				} else {
					mui.toast('服务器在开小差')
				}
			},
			error: function(xhr, type, errorThrown) {
				mui.toast('网络连接失败')

			}
		});
	},
	put: function(url) {
		var fun = this.backfun
		
		var close = this.closetask
		mui.ajax(this.baseurl + url, {
			data: this.data,
			headers: {
//				'Content-Type': 'application/json',
				'Authorization': localStorage.getItem("token")
			},
			dataType: 'json', //服务器返回json格式数据
			type: 'put', //HTTP请求类型
			timeout: 10000, //超时时间设置为10秒；
			success: function(data) {
				console.log(data)

				if(data["code"] == 200) {
					fun(data)
					close()

				} else {
					mui.toast('服务器在开小差')
				}
			},
			error: function(xhr, type, errorThrown) {
				mui.toast('网络连接失败')

			}
		});
	}
}